<template>
  <edu-dialog
    :title.sync="dialog.title"
    :visible.sync="dialog.showDialog"
    @close="close"
    width="400px"
    :showFooter="false"
  >
    <el-form
      ref="dialogForm"
      label-position="top"
      :model="dialog.formData"
      :rules="dialog.rules"
      label-width="230px"
      size="small"
    >
      <el-row>
        <el-col :span="24">
          <el-form-item label="帐号" prop="accountId">
            {{ dialog.formData.accountId }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="用户名" prop="accountName">
            {{ dialog.formData.accountName }}
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </edu-dialog>
</template>

<script>
import { resetPassword } from "@/api/users";
import utils from "@/utils";
import md5 from "md5";

export default {
  data() {
    return {
      dialog: {
        title: "用户信息",
        showDialog: false,
        formData: {},
        rules: {},
      },
    };
  },
  created() {},
  methods: {
    open() {
      let userInfo = utils.getlocalStorage("userInfo") || {};
      this.dialog.formData = {};
      this.dialog.formData = utils.clone(userInfo);

      this.dialog.showDialog = true;
    },
    close() {
      this.dialog.formData = {};

      this.dialog.showDialog = false;
    },
    // 重置密码
    async confirm() {
      console.log(resetPassword);
      resetPassword({
        accountId: this.dialog.formData.accountId,
        oldPassword: md5(this.dialog.formData.oldPassword),
        newPassword: md5(this.dialog.formData.newPassword),
      }).then((res) => {
        this.$message({
          type: "success",
          message: "密码修改成功",
        });
        this.close(this.dialog);
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
